using System;
using System.Collections.Generic;
using System.Text;

namespace Colman.Rpg.Npc
{
    /// <summary>
    /// Represents any monster (non-player character).
    /// </summary>
    [Serializable]
    public class Monster : Character
    {
        /// <summary>
        /// Creates a new instance of <see cref="Monster" />.
        /// </summary>
        /// <param name="fightingAgainst">Who the monster should fight against.</param>
        public Monster(Player fightingAgainst) : base("A Scary Monster")
        {
            // Check to see that fightingAgainst is not null
            if (fightingAgainst == null)
                throw new ArgumentNullException("fightingAgainst");

            // Always be able to beat the monster you see.
            this.DP = (fightingAgainst.CombinedAP > 1 ? randomGen.Next(1, fightingAgainst.CombinedAP - 1) : 0);
            
            // The monster should always be able to beat you.
            this.AP = Convert.ToInt32(fightingAgainst.MaxHP / ((randomGen.NextDouble() * 5) + 3));

            if (this.AP < fightingAgainst.CombinedDP)
                this.AP = fightingAgainst.CombinedDP + 1;

            // The monster should always be about as healthy as you (it eats its vegetables).
            this.MaxHP = Convert.ToInt32(fightingAgainst.CombinedAP * ((randomGen.NextDouble() * 5) + 3));

            if (this.MaxHP <= 0)
                this.MaxHP = 1;

            this.HP = this.MaxHP;
        }

        /// <summary>
        /// Not implemented - monsters can not defend.
        /// </summary>
        /// <param name="enemy">The enemy the character is fighting.</param>
        /// <returns>The amount of HP healed.</returns>
        /// <exception cref="NotSupportedException">Thrown on every call.</exception>
        public override int Defend(Character enemy)
        {
            throw new NotSupportedException("Monsters can not defend.");
        }
    }
}
